package com.example.smartplay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.smartplay.entity.Inform;
import com.example.smartplay.entity.Result;
import com.example.smartplay.mapper.InformMapper;
import com.example.smartplay.service.InformService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.sql.Wrapper;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2024-07-26
 */
@Service
public class InformServiceImpl extends ServiceImpl<InformMapper, Inform> implements InformService {
    @Autowired
    private InformMapper informMapper;
    //分页查询公告
    @Override
    public Result getinform(String keyword, Integer pageNum, Integer pageSize) {
        Page<Inform> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<Inform> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.hasText(keyword), Inform::getTitle, keyword).or()
                .like(StringUtils.hasText(keyword), Inform::getContent, keyword);


        return Result.success(informMapper.selectPage(page, wrapper));

    }
}
